<html>
<head><meta charset="utf-8"><title>opaque type aliases in fields in type_alias_impl_trait · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/opaque.20type.20aliases.20in.20fields.20in.20type_alias_impl_trait.html">opaque type aliases in fields in type_alias_impl_trait</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="247303244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/opaque%20type%20aliases%20in%20fields%20in%20type_alias_impl_trait/near/247303244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BN <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/opaque.20type.20aliases.20in.20fields.20in.20type_alias_impl_trait.html#247303244">(Jul 27 2021 at 07:44)</a>:</h4>
<p>In <a href="https://github.com/rust-lang/rust/issues/86732">#86732</a> we wanted to forbid impl trait type aliases in fields of structs, enums and unions in <code>min_type_alias_impl_trait</code>. Since we now plan to transition directly to <code>type_alias_impl_trait</code>, do we still want to reject them in fields? If not, what changes do we need to make to allow them in those positions?</p>



<a name="247326315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/opaque%20type%20aliases%20in%20fields%20in%20type_alias_impl_trait/near/247326315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/opaque.20type.20aliases.20in.20fields.20in.20type_alias_impl_trait.html#247326315">(Jul 27 2021 at 12:30)</a>:</h4>
<p>That's the beautiful thing with the new scheme that I'm building right now: No additional changes are needed, these will just work. I don't think we'll support <code>struct Foo { x: impl Debug }</code> for now, but <code>type Bar = impl Debug; struct Foo { x: Bar }</code> will just work</p>



<a name="247329740"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/opaque%20type%20aliases%20in%20fields%20in%20type_alias_impl_trait/near/247329740" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BN <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/opaque.20type.20aliases.20in.20fields.20in.20type_alias_impl_trait.html#247329740">(Jul 27 2021 at 13:03)</a>:</h4>
<p>Why would the type alias work, but not impl trait?</p>



<a name="247331596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/opaque%20type%20aliases%20in%20fields%20in%20type_alias_impl_trait/near/247331596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/opaque.20type.20aliases.20in.20fields.20in.20type_alias_impl_trait.html#247331596">(Jul 27 2021 at 13:19)</a>:</h4>
<p>well, it depends on what behaviour you expect from it. Is <code>fn foo(y: Foo) { let a: i32 = y.x; }</code> a defining use? or only <code>fn foo(mut y: Foo) { y.x = 42_i32; }</code>? This gets weird really fast, because the type system is (safe for diagnostics) commutative. So whether you compare <code>a == b</code> or <code>b == a</code> doesn't matter.</p>



<a name="247331650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/opaque%20type%20aliases%20in%20fields%20in%20type_alias_impl_trait/near/247331650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/opaque.20type.20aliases.20in.20fields.20in.20type_alias_impl_trait.html#247331650">(Jul 27 2021 at 13:19)</a>:</h4>
<p>this was the reason <code>impl_trait_in_bindings</code> was so horribly broken (like 10 open issues that ICEd the compiler)</p>



<a name="247331729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/opaque%20type%20aliases%20in%20fields%20in%20type_alias_impl_trait/near/247331729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/opaque.20type.20aliases.20in.20fields.20in.20type_alias_impl_trait.html#247331729">(Jul 27 2021 at 13:20)</a>:</h4>
<p>We'll need to figure out what we actually want/need</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>